import { BaseItem } from "../common/BaseItem";
import { PackConst } from "../../control/data/PackConst";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { DragManager } from "../../../../com/mui/manager/DragManager";
import { ListData } from "../../../../fl/controls/listClasses/ListData";
import { Language } from "../../../../extend/language/Language";
//class PackExtendItem
    
    export  class PackExtendItem extends BaseItem
    {
        constructor()
        {
            super();
            _bitmap.x = 3;
            _bitmap.y = 3;
            this.posType = PackConst.extendPosType;
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1 && itemData) 
            {
                this.filters = [FilterConst.itemChooseFilter];
            }
            else 
            {
                this.filters = [];
            }
            return;
        }

        protected /* override */ resetBitmapSize(): void
        {
            if (_bitmap) 
            {
                _bitmap.width = _width - 4;
                _bitmap.height = _height - 4;
            }
            return;
        }

        /* internal  */showFastBuy(): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.PackFastBuyPackage));
            return;
        }

        protected /* override */ onMouseDown(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (itemData) 
            {
                DragManager.instance.startDragItem(this);
            }
            else if (this.isOpened) 
            {
                flash.utils.setTimeout(this.showFastBuy, 10);
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(OpenBackPackExtendItemRequest));
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this.isOpened = arg1["isOpened"];
            this.selected = arg1["selected"];
            if (arg1.hasOwnProperty("itemData")) 
            {
                this.itemData = arg1["itemData"];
            }
            else 
            {
                this.itemData = null;
            }
            return;
        }

        public /* override */ set listData(arg1: ListData)
        {
            super.listData = arg1;
            this.posIndex = listData.index + 1;
            return;
        }

        public static get OpenBackPackExtendItemRequest(): string
        {
            return Language.getString(40062);
        }

        /* internal */ /* var */isOpened: Boolean=true;
    }
